package fluxx.mvc;

import java.util.Scanner;

import fluxx.draft.AbstractCardSet;
import fluxx.draft.Card;
import fluxx.draft.CardSet;
import fluxx.draft.Player;

public class TextView implements View {
	private Model model;
	private Control control;
	public TextView (Model model) {
		this.model = model;
		String[] adjectives = {"enticing", "rambling", "outrageous", "boring", "fun", "cool"};
		String phrase = adjectives[(int) (Math.random() * adjectives.length)];
		System.out.println("Welcome to a new, "+phrase+" game of Fluxx!");
	}
	
	public void update () {
		
	}

	@Override
	public Card pickFromDiscardPile() {
		return getUserPick("Please pick a card from the discard pile",
				model.getDiscard());
	}

	@Override
	public Card pickFromHand(Player player) {
		return getUserPick("Please choose a card from "
				+player.getName()+"'s hand", model.getHand(player));
	}

	@Override
	public Card pickFromKeepers(Player player) {
		return getUserPick("Please choose a keeper from "
				+player.getName(), model.getKeepers(player));
	}

	@Override
	public Card pickFromRules() {
		return getUserPick("Please choose a rule card", model.getRules());
	}
	
	private Card getUserPick(String message, AbstractCardSet fromSet) {
		System.out.println(message+" {"+fromSet+"}");
		System.out.print("# ");
		Scanner scanner = new Scanner(System.in);
		int index = scanner.nextInt();
		return fromSet.get(index);
	}
}
